//
//  GQJEqualViewController.m
//  TotalDemo
//
//  Created by gujian on 16/8/17.
//  Copyright © 2016年 gujian. All rights reserved.
//

#import "GQJEqualViewController.h"
#import "TestCopy.h"

@interface GQJEqualViewController ()

@end

@implementation GQJEqualViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSMutableArray *arr1 = [NSMutableArray arrayWithCapacity:3];
    NSMutableArray *arr2 = [NSMutableArray arrayWithCapacity:4];
    NSMutableArray *arr3 = [NSMutableArray arrayWithCapacity:3];
    
    for (int i = 0; i < 3; i++) {
        TestCopy *temp = [[TestCopy alloc] init];
        [arr1 addObject:temp];
        [arr2 addObject:temp];
    }
    
    [arr2 addObject:[[TestCopy alloc] init]];
    
    for (int i = 0; i < 3; i++) {
        TestCopy *temp = [[TestCopy alloc] init];
        [arr3 addObject:temp];
    }
    
    NSLog(@"isEqual:%d",[arr1 isEqualToArray:arr2]);
    NSLog(@"isEqual:%d", [arr1 isEqualToArray:arr3]);
    
    
    //会先比较arr1和arr2的内存地址是否一样
    //然后比较每个元素
    //如果两个元素的内存地址一样，则不调用具体实例的isEqual方法
    //如果不一致，则调用两个元素的isEqual方法
    
    //    arr2 = [NSMutableArray arrayWithArray:[[arr2 reverseObjectEnumerator] allObjects]];
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
